<template>
	<view >
		<!-- 登陆模块 -->
		<u--input
			    placeholder="手机/邮箱/用户名"
			    prefixIconStyle="font-size: 22px;color: #909399"
				style="border: 0px;border-bottom: 1px solid black;"
				v-model="form.username"
			></u--input>
			<u--input
				    placeholder="密码"
					v-model="form.password"
				    prefixIconStyle="font-size: 22px;color: #909399"
					style="border: 0px;border-bottom: 1px solid black;"
			></u--input>
			
			<u-button @click="tiao" type="primary" style="background-color: green;border: 0px;border-radius: 20px;" :disabled="disabled" text="登录"></u-button>
		
	</view>
</template>

<script>
	export default {
		name:"regis",
		data() {
			return {
				form:{
					username:'',
					password:''
				},
				info:{},
				checked:false,
				disabled:false
			};
		},
		methods:{
			async tiao(){
				if(this.form.username==null&&this.form.password==null){
					uni.showToast({
						icon:'error',
						title:"请输入用户名和密码"
					})
				}else{
					const {data} = await this.$request.login(this.form)
					console.log(data)
					this.info=data.data
					if(data.code==-1){
						uni.showToast({
							icon:"error",
							title:"用户名或密码错误"
						})
					}else{
						uni.showToast({
							icon:"success",
							title:"登录成功",
							success() {
								uni.setStorageSync('user_id',this.user_id)
								setTimeout(()=>{
									uni.switchTab({
										url:"/pages/index/index"
									})
								},1500)
							}
						})
					}
				}
				
				// uni.switchTab({
				// 	url:"/pages/index/index"
				// })
			}
		}
	}
</script>

<style>

</style>